<?php

class Talktangle_Plugin_Menus
{
 
  public function onMenuInitialize_TalktangleProfileFollow($row)
  {
    
    $viewer = Engine_Api::_()->user()->getViewer();
    $subject = Engine_Api::_()->core()->getSubject();
    
    
    if( !$viewer->getIdentity() || 
        !$subject->getIdentity() || 
        $viewer->isSelf($subject) ) {
      return false;
    } else {
        
        $followerTable = Engine_Api::_()->getDbtable('followers','talktangle');
        $isFollower = $followerTable->isFollower($viewer->user_id,$subject->user_id);
        if($isFollower) return false;
        
      return array(
        'label' => 'Follow',
        'icon' => 'application/modules/Core/externals/images/report.png',
        'class' => 'smoothbox',
        'route' => 'default',
        'params' => array(
          'module'  =>'talktangle',
          'controller' => 'follow',
          'action' => 'follow',
          'object_id' => $subject->getIdentity(),
          'format' => 'smoothbox',
        ),
      );
    }
  }
  
  public function onMenuInitialize_TalktangleFeed($row)
  {
     return array(
        'label' => 'Tangle Feed',
        'route' => 'talktangle_extended',
        'params' => array(
          
          'controller' => 'index',
          'action' => 'index'
          
        ),
      );
  }
  
  public function onMenuInitialize_TalktanglePromotions($row)
  {
     return array(
        'label' => 'Promotions',
        'route' => 'talktangle_extended',
        'params' => array(
          
            'type' => 'mypromotion'
          
        ),
      );
  }
  public function onMenuInitialize_TalktangleVideo($row)
  {
     return array(
        'label' => 'Your Videos',
        'route' => 'talktangle_extended',
        'params' => array(
          
          'type' => 'filter',
          'id'   => 'vid'
          
          
        ),
      );
  }
 
  public function onMenuInitialize_TalktanglePic($row)
  {
     return array(
        'label' => 'Your Pics',
        'route' => 'talktangle_extended',
        'params' => array(
          
          'type' => 'filter',
          'id'   => 'pic'
          
        ),
      );
  }
  
  public function onMenuInitialize_TalktangleFriend($row)
  {
    $viewer = Engine_Api::_()->user()->getViewer();
    if($viewer->type == 'company'){
         return array(
            'label' => 'Your Followers',
            'route' => 'talktangle_extended',
            'params' => array(
              
              'type' =>'followers'
              
            ),
          );        
    }
    else{
        return array(
            'label' => 'Your Friends',
            'route' => 'talktangle_extended',
            'params' => array(
              
              'type' =>'friend'
              
            ),
          );      
    }
  }

  
  public function onMenuInitialize_TalktangleProfileUnfollow($row)
  {
    $viewer = Engine_Api::_()->user()->getViewer();
    $subject = Engine_Api::_()->core()->getSubject();

    if( !$viewer->getIdentity() || 
        !$subject->getIdentity() || 
        $viewer->isSelf($subject) ) {
      return false;
    } else {
        $followerTable = Engine_Api::_()->getDbtable('followers','talktangle');
        $isFollower = $followerTable->isFollower($viewer->user_id,$subject->user_id);
        if(!$isFollower) return false;
      return array(
        'label' => 'UnFollow',
        'icon' => 'application/modules/Core/externals/images/report.png',
        'class' => 'smoothbox',
        'route' => 'default',
        'params' => array(
          'module'  =>'talktangle',
          'controller' => 'follow',
          'action' => 'unfollow',
          'object_id' => $subject->getIdentity(),
          'format' => 'smoothbox',
        ),
      );
    }
  }
  public function onMenuInitialize_CoreMainTalktangle($row)
  {
     return array(
        'label' => 'Taktangle',
        'route' => 'talktangle_extended',
        'params' => array(
          
          'type' =>'filter',
          'id'  => 'talk'
          
        ),
      );
  }
  

  
}